package stu.aistar.service.Impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import stu.aistar.mapper.OrdersMapper;
import stu.aistar.model.pojo.Orders;
import stu.aistar.service.IOrdersService;

import java.util.List;

@Service
public class IOrdersServiceImpl implements IOrdersService {
    @Autowired
    private OrdersMapper ordersMapper;
    @Override
    public Integer insertOrders(Orders orders) {
        Integer result=ordersMapper.insertOrders(orders);
        return result;
    }

    @Override
    public Integer updateOrdersState(String ordersNo) {
       Integer result=ordersMapper.updateOrdersState(ordersNo);
       return result;
    }

    @Override
    public List<Orders> findOrdersByUserId(Integer userId) {
        List<Orders> orders=ordersMapper.findOrdersByUserId(userId);
        return orders;
    }

    @Override
    public Orders findOrdersByOrdersNo(String ordersNo) {
        Orders orders=ordersMapper.findOrdersByOrdersNo(ordersNo);
        return orders;
    }

    @Override
    public PageInfo<Orders> findOrdersByPage(String page, String pageSize, String userName, String ordersNo, String state) {
        System.out.println(page);
        System.out.println(pageSize);
        System.out.println("username"+userName);
        System.out.println("ordersNo"+ordersNo);
        System.out.println("state"+state);
        PageHelper.startPage(Integer.valueOf(page),Integer.valueOf(pageSize));
        List<Orders> orders=ordersMapper.findOrdersByConditions(userName,ordersNo,state);
        PageInfo<Orders> pageInfo=new PageInfo<Orders>(orders);
        System.out.println(pageInfo);
        System.out.println(123);
        return pageInfo;
    }


}
